#include "PCH.h"
#include "viewport.h"
#include "macros.h"
#include "Config.h"

ViewPort::ViewPort()
{
	w=h=tilex=tiley=0;
}

void ViewPort::SetSize(uint nw, uint nh)
{
	w = nw;
	h = nh;
}

void ViewPort::SetPos(sint cx, sint cy)
{
	tilex = cx-w/2;
	tiley = cy-h/2;
}

void ViewPort::Step(sint x, sint y)
{
	tilex+=x;
	if (tilex<=0)
		tilex=0;
	else if (tilex+_NUMTILESCRX>_SIZEMAP)
		tilex=_SIZEMAP-_NUMTILESCRX;

	tiley+=y;
	if (tiley<=0)
		tiley=0;
	else if (tiley+_NUMTILESCRY>_SIZEMAP)
		tiley=_SIZEMAP-_NUMTILESCRY;
}